<?php
/**
 * Description: 支付行为统计
 * User: devforma
 * Date: 16/9/12
 * Time: 10:24
 */

class PayLog implements iController {

    /**
     * api请求处理主函数
     * @param array $queryArgs 就是$_REQUEST变量
     * @return array api返回结果，必须含response_code
     */
    public function output($queryArgs) {
        global $uddb;

        if (validateUser($queryArgs) !== 1 || empty($queryArgs['level']) || !in_array($queryArgs['level'], ['pay_log_1', 'pay_log_2'])) {
            return genOutput(1000);
        }

        $record = $uddb->getRow('SELECT `id`, `misc_value` FROM `miscellaneous` WHERE `misc_name`=:name', [':name' => $queryArgs['level']]);
        $uddb->update('miscellaneous', ['misc_value' => $record->misc_value + 1], ['id' => $record->id]);

        return genOutput(1);
    }
}